﻿using System.Data.Entity;
using System.Transactions;

using CodingBlog.Core.Repository;

using NUnit.Framework;

namespace CodingBlog.Core.Tests
{
    abstract public class BaseRepositoryTest
    {
        private TransactionScope scope;

        [TestFixtureSetUp]
        public void InitOnceBeforeAllTests()
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<CodingBlogContext>());
            new BlogRepository().GetBlogsCount();
        }

        [SetUp]
        public void BeginTransaction()
        {
            scope = new TransactionScope();
        }

        [TearDown]
        public void RollbackTransation()
        {
            scope.Dispose();
        }
    }
}